package com.baiytfp.hf.HFDataExchange.action.controller.service;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.baiytfp.hf.HFDataExchange.action.service.DataDictService;
import com.baiytfp.hf.HFDataExchange.common.model.table.Data_dict;
import com.baiytfp.hf.baiytfp.hfutils.HFRequest;
import com.baiytfp.hf.baiytfp.hfutils.HFResponse;


@Controller
@RequestMapping("/service/api/datadict")
public class DataDictApiSController {
	
	@Autowired
	public DataDictService datadictService;
	
	/**
	 * 
	 * @param dataDictType
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value="/getdatadictlist", method= RequestMethod.POST)
	public ModelAndView getdatadictlist(HttpServletRequest request,HttpServletResponse response) throws Exception{
		
		String dataDictTypes = HFRequest.getIstance().getString(request,"dataDictType", "");
		
		String [] arry = dataDictTypes.split(",");
		
		List<List<Data_dict>> resultList = new ArrayList<List<Data_dict>>();
		
		for(String dataDictType: arry){
			List<Data_dict> list = new ArrayList<Data_dict>();
			if(!"".equals(dataDictType)){
				list = datadictService.getDataDictList(dataDictType);
			}
			resultList.add(list);
		}
		
		HFResponse.getIstance().returnResult(response, resultList);
		
		return null;
	}

}
